<template>
  <div class="box1">
    <div class="list" v-for="(item, index) in foodInf" :key="index">
      <img :src="item.icon" alt="">
      <div class="info">
        <h3>{{ item.name }}</h3>
        <p>{{ item.description }}</p>
        <p>月售{{ item.sellCount }}份&nbsp;好评率&nbsp;{{ item.rating }}%</p>
        <span>
          <span>￥{{ item.price }}<del><span>{{ item.oldPrice }}</span></del></span>
          <div class="btn">
            <button v-show="item.num" @click="minus(index)">-</button>
            <span v-show="item.num">{{ item.num }}</span>
            <button @click="add(index)">+</button>
          </div>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
import axios from 'axios'

export default {
  data() {
    return {
      // hire: true,
    }
  },
  created() {
    this.$store.dispatch('getGoods');
  },
  computed: {
    ...mapState(['foodInf','goodsInf'])
  },
  methods: {
    ...mapActions(['getGoods']),
    ...mapMutations(['add', 'addCarInf', 'minus']),
  }
}
</script>

<style scoped>
.box1 {
  overflow: auto;
  height: 155vw;
  background-color: #f3f5f7;
}

.box1>.list {
  background-color: white;
  padding: 4.68vw 0vw 4.68vw 4.68vw;
  display: flex;
  width: 100%;
  border-bottom: 0.13vw solid rgba(7, 17, 27, 0.1);
}

.list img {
  height: 17.5vw;
  margin-right: 2.6vw;
}

.list h3 {
  font-size: 3.64vw;
  margin-top: 0vw;
}

.info {
  font-size: 1.56vw;
  width: 100%;
}

.info p {
  color: gray;
  margin-top: 2.08vw;
}

.info span {
  color: red;
}

.info span span {
  font-size: 4vw;
  font-weight: 900;
  margin-right: 2.08vw;
}

.info span del {
  color: gray;
  font-size: 1.6vw;
}

.info span del span {
  color: gray;
  font-size: 1.6vw;
}

.info>span{
  display: flex;
  position: relative;
}
.btn{
  position: absolute;
  right: 36px;
}
.btn button{
  width: 6.24vw;
  height: 6.24vw;
  line-height: 6.24vw;
  border-radius: 50%;
  background-color: white;
  text-align: center;
  border: 0;
}
.btn button:nth-of-type(1){
  font-size: 6.24vw;
  box-sizing: border-box;
  color: rgb(0,160,220);
  margin-right: 3.24vw;
  position: absolute;
  border: 0.65vw solid rgb(0,160,220);
  right: 8.24vw;
  line-height: 3.24vw;
  box-sizing: border-box;
}
.btn button:nth-of-type(2){
  font-size: 6.24vw;
  right: 0;
  color: white;
  background-color:rgb(0,160,220) ;
}
.btn span{
  position: absolute;
  right: 4.5vw;
  line-height: 6.24vw;
}
</style>